/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : SysUart.h
  * @brief          : 串口操作
  ******************************************************************************
  ** 本文件用于声明串口操作相关的程序，包括初始化、波特率设置、接收回调和发送回调等
  * 
  *	
  ******************************************************************************
  */
/* USER CODE END Header */

#ifndef __SYS_UART__
#define __SYS_UART__

/* USER CODE BEGIN Includes */

#include "alldefine.h"
#include "main.h"


/* USER CODE END Includes */
/*******************************************************************************************************/



/* USER CODE BEGIN  Define */

#define UART_RXSIZE 400
#define UART_TXSIZE 400

/* USER CODE END  Define */

/*******************************************************************************************************/



/* USER CODE BEGIN Typedef */

/* 
*		串口接收结构体
*		uint8_t						Start								串口接收状态 	0=串口未接收完成/串口无数据
*																												1=串口接收到一帧数据需要处理
*		uint16_t 					Size								串口接收数据长度
*		uint8_t 					Buf[UART_RXSIZE]		串口接收数据存储的BUF
*
*/
typedef struct
{
	
	uint8_t						Start;
	uint16_t 					Size;
	uint8_t 					Buf[UART_RXSIZE];
	
}tUartRxBufDef;


/* 
*
*		UART_TX_IDLE		UART发送空闲
*		UART_TX_BUSY		UART发送中
*
*/

typedef enum
{
	
	UART_TX_IDLE=0,
	UART_TX_BUSY
}tUartTxStartDef;

typedef struct
{
	
	tUartTxStartDef		Start;
	uint8_t 					Buf[UART_RXSIZE];
	
}tUartTxBufDef;


/* USER CODE END Typedef */

/*******************************************************************************************************/



/* USER CODE BEGIN Private variables */


extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
//extern UART_HandleTypeDef huart3;
//extern UART_HandleTypeDef huart4;
//extern UART_HandleTypeDef huart5;

extern tUartRxBufDef Uart1RxBuf;
extern tUartRxBufDef Uart2RxBuf;
//extern tUartRxBufDef Uart3RxBuf;
//extern tUartRxBufDef Uart4RxBuf;
//extern tUartRxBufDef Uart5RxBuf;

/* USER CODE END Private variables */

/*******************************************************************************************************/

/* USER CODE BEGIN  Function prototypes */


extern	void UartInit(UART_HandleTypeDef *huart,uint32_t bps,uint16_t pay);

extern 	void UartBufInit(UART_HandleTypeDef *huart,tUartRxBufDef *UartRxBuf);

extern 	void UartSend(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size);

extern 	void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart);

extern	void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart);



/* USER CODE END  Function prototypes */


/*******************************************************************************************************/



#endif
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

